package cn.car91.activity;

import java.util.List;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.TextView;
import cn.car91.R;
import cn.car91.adapter.TechnologyListAdapter;
import cn.car91.view.HerilyAlertDialog.Builder;
import cn.car91.view.MyListView;
import cn.car91.view.WordWrapView;

import com.lidroid.xutils.view.annotation.ViewInject;

public class RepairShopHardTechActivity extends BaseActivity {
  
  @ViewInject(R.id.repairshop_hardware_all)
  WordWrapView hardwareView;
  @ViewInject(R.id.repairshop_technology_all)
  MyListView technologyView;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_repairshop_techhard);
    super.onCreate(savedInstanceState);
    
    try {
      ((TextView) findViewById(R.id.header_text)).setText(getIntent().getStringExtra("repairshop_name"));
      
      List<String> allTechs = getIntent().getStringArrayListExtra("repairshop_technology");
      List<String> allHards = getIntent().getStringArrayListExtra("repairshop_hardware");
      
      if(allHards != null) {
          for (String h : allHards) {
              hardwareView.addView(createTextView(h));
            }
      }
      
      if(allTechs != null) {
          TechnologyListAdapter technologyListAdapter = new TechnologyListAdapter(this);
          technologyListAdapter.setData(allTechs);
          technologyView.setAdapter(technologyListAdapter);
      }
    } catch (Exception e) {
      new Builder(this).setMessage("数据加载异常").create().show();;
    }
    
  }
  
  private TextView createTextView(String text){
      TextView textView = (TextView) LayoutInflater.from(this).inflate(R.layout.view_service_item, null);
      textView.setText(text);
      return textView;
  }

}
